package com.webtest.demo;

import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;

import com.webtest.dataprovider.ExcelDataProvider;

public class LiuChengTest extends com.webtest.core.LiuChengBase{

	@DataProvider(name="notice")
	public Object[][] getNoticeData() throws Exception{
		return new ExcelDataProvider().getTestDataByExcel("D:\\test\\auto\\data\\notice.xlsx", "Sheet1");
	}
	@DataProvider(name="knowledge")
	public Object[][] getKnowledgeData() throws Exception{
		return new ExcelDataProvider().getTestDataByExcel("D:\\test\\auto\\data\\knowledge.xlsx", "Sheet1");
	}
	
	//批量新增通知公告
	@Test(dataProvider="notice")
	public void testPublishNotice(String title,String typename) {
		webtest.click("id=menu_list_num42");
		webtest.click("xpath=//a[text()='通知公告']");
		webtest.enterFrame(0);
		webtest.type("xpath=//input[@type='text']", title);
		webtest.selectByValue("name=typename", typename);
		webtest.click("id=AltS");	
	}
	//批量新增知识
	@Test(dataProvider="knowledge")
	public void testPublishKnowledge(String title,String typeid) {
		webtest.click("id=menu_list_num42");
		webtest.click("xpath=//a[text()='知识']");
		webtest.enterFrame(0);
		webtest.type("xpath=//input[@type='text']", title);
		webtest.selectByValue("name=typeid", typeid);
		webtest.click("id=AltS");	
	}
	//导出我的申请
	@Test
	public void test1() {
		webtest.click("id=menu_list_applymy");
		webtest.click("xpath=//button[text()='导出']");
	}
	//查看申请详情
	@Test
	public void test2() {
		webtest.click("id=menu_list_applymy");
		webtest.click("xpath=//a[@oi='0']");
		webtest.click("xpath=/html/body/div[1]/div/ul/li[1]");
		webtest.leaveFrame();
	}
	//直达尾页
	@Test
	public void test3() {
		webtest.click("id=menu_list_applymy");
		webtest.click("xpath=//button[@title='尾页']");
	}
	//修改每页条数
	@Test
	public void test4() {
		webtest.click("id=menu_list_applymy");
		webtest.type("xpath=//input[starts-with(@id,'pagesize_')]", "5");
		webtest.click("xpath=//button[@title='刷新']");
	}
	//双击直接查看申请详情
	@Test
	public void test5() throws InterruptedException {
		webtest.click("id=menu_list_applymy");
		webtest.doubleClick("xpath=//td[@row='0' and @cell='0']");
		webtest.leaveFrame();
	}
	//将申请日期降序排列
	@Test
	public void test6() {
		webtest.click("id=menu_list_applymy");
		webtest.click("xpath=//i[@tempsort='4' and @lx='desc']");
	}
	//选择模块
	@Test
	public void test7() {
		webtest.click("id=menu_list_num62");
		webtest.selectByValue("xpath=//select[starts-with(@id,'mode_')]", "4");
	}
	//按条件搜索申请
	@Test
	public void test8() {
		webtest.click("id=menu_list_num62");
		webtest.type("xpath=//input[starts-with(@id,'key_')]", "开发部");
		webtest.click("xpath=//button[text()='搜索']");
	}
	//筛选“待审核”申请
	@Test
	public void test9() {
		webtest.click("id=menu_list_num44");
		webtest.click("xpath=//button[text()='待审核']");
	}
	//在导航处搜索
	@Test
	public void test10() {
		webtest.click("id=indesearchmenu");
		webtest.type("id=confirm_input", "我的申请");
		webtest.click("id=confirm_btn1");
	}

	//隐藏/打开旁侧的导航栏
	@Test
	public void test11() {
		webtest.click("id=reordershla");
		webtest.click("id=indexmenuss");
	}


	//退出系统
	@Test
	public void testLogout() {
		webtest.click("id=indexuserl");
		webtest.click("xpath=/html/body/div[1]/div/ul/li[6]");
		webtest.click("id=confirm_btn1");
	}

}
